package mobi.greenplate.client.handler;

import mobi.greenplate.client.converter.AddressConverter;
import mobi.greenplate.client.domain.Address;
import mobi.greenplate.client.parser.DomainHandler;

/**
 *
 * @author dmakariev
 */
public class AddressHandler extends DomainHandler<Address> {

    private static final String ADDRESS_ROOT = "//address";
    private Address address = new Address();

    @Override
    public Address getEntity() {
        return address;
    }

    @Override
    public void endTag(String parentPath, String tagName, String text) {
        if (ADDRESS_ROOT.equalsIgnoreCase(parentPath)) {
            address = AddressConverter.endTag(address, tagName, text);
        }
    }

    @Override
    public void startTag(String parentPath, String tagName) {
        //do nothing
    }
}
